<!DOCTYPE html>
<html>

<head>
    <title>H-Cloud</title>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="./assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="./assets/css/login.css" media="all">
    <link rel="stylesheet" href="./assets/css/star.css">

    <script>
        if (window != top)
            top.location.replace(location.href);
    </script>
</head>

<!--<body style="background-image: url('assets/images/background.png')">-->
<body >

<div class="star comet " ></div>

<div class="login-wrapper" style="z-index: 9999">

    <div class="login-header">
        <img src="assets/images/logo.png">
    </div>

    <div class=" login-body">
        <div class="layui-card">
            <div class="layui-card-header">
                <i class="layui-icon layui-icon-engine"></i>&nbsp;&nbsp;用户登录
            </div>
            <form class="layui-card-body layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
                    <div class="layui-input-block">
                        <input name="username" type="text" lay-verify="required" placeholder="账号"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
                    <div class="layui-input-block">
                        <input name="password" type="password" lay-verify="required" placeholder="密码"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-vercode"></i></label>
                    <div class="layui-input-block">
                        <div class="layui-row inline-block">
                            <div class="layui-col-xs7">
                                <input name="code" type="text" lay-verify="required" placeholder="验证码"
                                       class="layui-input">
                            </div>
                            <div class="layui-col-xs5" style="padding-left: 10px;">
                                <img class="login-captcha" src="">
                            </div>
                        </div>
                    </div>
                </div>
                <input type="hidden" id = "uuid" value="">
                <!--<div class="layui-form-item">-->
                    <!--<a href="javascript:;" class="layui-link">帐号注册</a>-->
                    <!--<a href="javascript:;" class="layui-link pull-right">忘记密码？</a>-->
                <!--</div>-->
                <div class="layui-form-item">
                    <button lay-filter="login-submit" class="layui-btn layui-btn-fluid" lay-submit>登 录</button>
                </div>
                <div class="layui-form-item login-other">
                    <label>第三方登录</label>
                    <a href="javascript:" id="weixin_login"><i class="layui-icon layui-icon-login-wechat"></i></a>
                    <a href="javascript:;" id="qq_login"><i class="layui-icon layui-icon-login-qq"></i></a>
                    <!--<a href="javascript:;"><i class="layui-icon layui-icon-login-weibo"></i></a>-->
                </div>
            </form>
        </div>
    </div>

    <div class="login-footer">
        <p>© 2018 <a href="https://easyweb.vip" target="_blank"> H-Cloud 版权所有</a></p>
        <p>
            <span><a href="https://gitee.com/HePanGui/h-cloud" target="_blank">前往gitee</a></span>
            <!--<span><a href="http://easyweb.vip" target="_blank">文档说明</a></span>-->
        </p>
    </div>
</div>
<script src="./assets/js/star.js"></script>
<script type="text/javascript" src="./assets/libs/layui/layui.js"></script>
<script>
    layui.config({
        base:"./module/"
    })

    layui.use(['layer', 'form','config','login'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var config = layui.config;
        var login = layui.login;
        config.removeUser();
        login.codeAutoLogin();

        // 表单提交
        form.on('submit(login-submit)', function (obj) {
            layer.load(2);
            $.ajax({
                url:"auth/auth/pass?code="+obj.field.code+"&randomUuid="+$("#uuid").val(),
                type:"post",
                data:{
                    username:obj.field.username,
                    password:obj.field.password,
                    // code:obj.field.code,
                    grant_type:"password",
                    // randomUuid:$("#uuid").val(),
                    scope:"font"
                },
                headers:login.headers,
                dataType:"json",
                success:login.loginSuccess,
                error:login.loginError
            })
            return false;
        });
        // 初始化图形验证码
        $('.login-captcha').attr("src","./code?uuid="+login.guid());
        // 图形验证码
        $('.login-captcha').click(function () {
            this.src =  "./code?uuid="+login.guid();
        });

        $("#weixin_login").click(function(){
            var appid = config.weixinappid;
            var number = location.href.indexOf("?");
            if(number == -1){
                number = location.href.indexOf("#");
            }
            if(number==-1){
                var redirect_uri =encodeURI(location.href);
            }else{
                var redirect_uri =encodeURI(location.href.substring(0,number));
            }
            location.href="https://open.weixin.qq.com/connect/qrconnect?appid="+appid+"&redirect_uri="+redirect_uri+"&state=weixin&response_type=code&scope=snsapi_login#wechat_redirect"
        })

        $("#qq_login").click(function(){
            var appid = config.qqappid;
            var number = location.href.indexOf("?");
            if(number == -1){
                number = location.href.indexOf("#");
            }
            if(number==-1){
                var redirect_uri =encodeURI(location.href);
            }else{
                var redirect_uri =encodeURI(location.href.substring(0,number));
            }
            location.href="https://graph.qq.com/oauth2.0/authorize?response_type=code&state=qq&client_id=" + appid + '&redirect_uri=' + redirect_uri;
        })



    });
</script>
</body>
</html>